package com.njtoyo.taxi.admin.rest.controller.business.operation_rule;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njtoyo.taxi.admin.rest.presenter.business.operation_rule.InformationServiceFeePresenter;
import com.njtoyo.taxi.admin.rest.presenter.business.operation_rule.SimpleCallInfoServiceFeeRulePresenter;
import com.njtoyo.taxi.admin.rest.wrapper.business.operation_rule.InformationServiceFeeWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.operation_rule.SimpleCallServiceRuleAddUpdateWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.marketing.freeCommission.FreeCommissionCardUpdateWrapper;
import com.njtoyo.taxi.admin.service.business.operation_rule.SimpleCallInfoServiceFeeRuleService;
import com.taxi.entity.common.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 一键叫车信息服务费
 */
@RestController
@RequestMapping("business/operation-rule/simpleCall-service-rule")
public class SimpleCallInfoServiceFeeRuleController {


    @Autowired
    private SimpleCallInfoServiceFeeRuleService simpleCallInfoServiceFeeRuleService;


    @GetMapping("/list")
    RestResult<IPage<SimpleCallInfoServiceFeeRulePresenter>> list(@RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                                                                  @RequestParam(value = "size", required = false, defaultValue = "15") Integer size,
                                                                  @RequestParam(value = "driverRegionName", required = false) String driverRegionName) {
        IPage<SimpleCallInfoServiceFeeRulePresenter> page = simpleCallInfoServiceFeeRuleService.getPage(current, size, driverRegionName);
        return RestResult.success(page);
    }


    @PostMapping("/add")
    RestResult add(@RequestBody SimpleCallServiceRuleAddUpdateWrapper wrapper) {
        return simpleCallInfoServiceFeeRuleService.add(wrapper);
    }


    @PostMapping("/update")
    RestResult update(@RequestBody SimpleCallServiceRuleAddUpdateWrapper wrapper) {
        return simpleCallInfoServiceFeeRuleService.update(wrapper);
    }


    @GetMapping("/info/{id}")
    RestResult getInfoById(@PathVariable("id") Long id) {
        if (ObjectUtil.isNull(id)) {
            return RestResult.failed("缺少必要参数:ID");
        }
        return simpleCallInfoServiceFeeRuleService.getInfoById(id);
    }

    @DeleteMapping("/delete/{id}")
    RestResult delete(@PathVariable("id") Long id) {
        if (ObjectUtil.isNull(id)) {
            return RestResult.failed("缺少必要参数:ID");
        }
        return simpleCallInfoServiceFeeRuleService.deleteById(id);
    }


    @PostMapping("/updateActive")
    public RestResult updateActive(@RequestBody SimpleCallServiceRuleAddUpdateWrapper wrapper) {
        return simpleCallInfoServiceFeeRuleService.updateActive(wrapper);
    }



}
